package com.bjb.vr.operation.controller;

import com.bjb.vr.common.ao.OptHelpDocAo;
import com.bjb.vr.common.result.BaseErrorCode;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.common.service.OptHelpDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0.0
 * @description:
 * @author: caihaibo
 * @createDate: 2022/6/16
 */
@RestController
@RequestMapping("/api/operation/v1")
public class HelpDocController {

    @Autowired
    OptHelpDocService optHelpDocService;


    /**
     * 帮助文档查询列表接口
     * @param optHelpDocAo
     * @return
     */
    @PostMapping("/queryHelpDocList")
    public BaseResult queryHelpDocList(@RequestBody OptHelpDocAo optHelpDocAo){

        return CommonResult.Ok().setResult(optHelpDocService.queryHelpDocList(optHelpDocAo));
    }

    /**
     * 增加帮助文档接口
     * @param optHelpDocAo
     * @return
     */
    @PostMapping("/addHelpDoc")
    public BaseResult addHelpDoc(@RequestBody OptHelpDocAo optHelpDocAo){
        boolean success = optHelpDocService.addHelpDoc(optHelpDocAo);
        if(!success){
            return CommonResult.Fail(BaseErrorCode.ERROR_ADD);
        }
        return CommonResult.Ok();
    }

    @PostMapping("/updateHelpDoc")
    public BaseResult updateHelpDoc(@RequestBody OptHelpDocAo optHelpDocAo){
        boolean success = optHelpDocService.updateHelpDoc(optHelpDocAo);
        if(!success){
            return CommonResult.Fail(BaseErrorCode.ERROR_UPDATE);
        }
        return CommonResult.Ok();
    }


    @PostMapping("/deleteHelpDoc")
    public BaseResult deleteHelpDoc(@RequestBody OptHelpDocAo optHelpDocAo){
        boolean success = optHelpDocService.deleteHelpDoc(optHelpDocAo);
        if(!success){
            return CommonResult.Fail(BaseErrorCode.ERROR_REMOVE);
        }
        return CommonResult.Ok();
    }


    @PostMapping("/queryHelpDocDetail")
    public BaseResult queryHelpDocDetail(@RequestBody OptHelpDocAo optHelpDocAo){

        return CommonResult.Ok().setResult(optHelpDocService.queryHelpDocDetail(optHelpDocAo));
    }
}
